package cn.buk.tms.dto;

import cn.buk.tms.dto.WeixinServiceUserDto;
import cn.buk.tms.entity.misc.User;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 用户名等登录相关信息
 * @author yfdai
 */
public class LoginInfoDto {

    public static LoginInfoDto createByUser(User u) {
        LoginInfoDto dto = new LoginInfoDto();
        BeanUtils.copyProperties(u, dto);

        if (u.getMobileNo().length() > 5 ) {
            dto.setMobile(u.getMobileNo());
        }

        return dto;
    }


    private String username;

    /**
     * 是否为临时用户名
     */
    private boolean temporaryUsername;

    private int id;

    private int enterpriseId;

    private int parentEnterprise;

    /**
     * 状态
     * 1 - 正常
     * 4 - 停用
     */
    private int status;

    private String empname;

    /**
     * eterm 用户名
     */
    private String etermUsername;

    private String email;

    private String mobile;


    /**
     * 备注
     */
    private String remark;


    /**
     * EOTMS的网址
     */
    private String eotmsUrl;

    /**
     * 部门名称
     */
    private String departmentName;

    /**
     * 部门ID
     */
    private Integer departmentId;

    /**
     * 职位名称
     */
    private String positionName;

    /**
     * 职位ID
     */
    private Integer positionId;

    /**
     * 用户名对应的乘机人信息id
     */
    private Integer passengerId;

    /**
     * 绑定的微信公众号的用户
     */
    private List<WeixinServiceUserDto> wxsUsers;

    public int getEnterpriseId() {
        return enterpriseId;
    }

    public void setEnterpriseId(int enterpriseId) {
        this.enterpriseId = enterpriseId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
        this.temporaryUsername = User.testTemporaryUsername(this.username);
    }

    public String getEmpname() {
        return empname;
    }

    public void setEmpname(String empname) {
        this.empname = empname;
    }

    public String getEmail() {
        return email == null ? "": email.trim();
    }

    public void setEmail(String email) {
        this.email = email;
    }


    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }


    public String getEtermUsername() {
        return etermUsername;
    }

    public void setEtermUsername(String etermUsername) {
        this.etermUsername = etermUsername;
    }

    public int getParentEnterprise() {
        return parentEnterprise;
    }

    public void setParentEnterprise(int parentEnterprise) {
        this.parentEnterprise = parentEnterprise;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public boolean isTemporaryUsername() {
        return temporaryUsername;
    }

    public String getEotmsUrl() {
        return eotmsUrl;
    }

    public void setEotmsUrl(String eotmsUrl) {
        this.eotmsUrl = eotmsUrl;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getMobile() {
        return mobile == null ? "": mobile.trim();
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getDepartmentName() {
        return departmentName;
    }

    public void setDepartmentName(String departmentName) {
        this.departmentName = departmentName;
    }

    public Integer getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(Integer departmentId) {
        this.departmentId = departmentId;
    }

    public String getPositionName() {
        return positionName;
    }

    public void setPositionName(String positionName) {
        this.positionName = positionName;
    }

    public Integer getPositionId() {
        return positionId;
    }

    public void setPositionId(Integer positionId) {
        this.positionId = positionId;
    }

    public Integer getPassengerId() {
        return passengerId;
    }

    public void setPassengerId(Integer passengerId) {
        this.passengerId = passengerId;
    }

    public List<WeixinServiceUserDto> getWxsUsers() {
        if (wxsUsers == null) {
            this.wxsUsers = new ArrayList<>();
        }
        return wxsUsers;
    }

    public void setWxsUsers(List<WeixinServiceUserDto> wxsUsers) {
        this.wxsUsers = wxsUsers;
    }
}
